// LEDMatrixDisplay.h
#ifndef LED_MATRIX_DISPLAY_H
#define LED_MATRIX_DISPLAY_H

#pragma once
#include <FastLED.h>
#include "DisplayLayout.h"

#define PIN 8  // 固定使用引脚8

class LEDMatrixDisplay {
public:
    LEDMatrixDisplay(uint8_t pin, uint16_t width, uint16_t height);
    ~LEDMatrixDisplay();
    void begin();
    void clear();
    void show();
    void setBrightness(uint8_t brightness);
    void displayTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint8_t dayOfWeek);
    void setTimeColor(CRGB hourColor, CRGB minColor, CRGB secColor);
    void setColonColor(CRGB colonColor);
    void setDateColor(CRGB dateColor);
    void setWeekColors(CRGB activeColor, CRGB inactiveColor);
    void animateColons();
    DisplayLayout& getLayout() { return layout; }
    
    // 添加公共访问方法
    CRGB getDateColor() { return dateColor; } // 移到公共区域
    
    // 测试方法
    void fillScreen(CRGB color);
    void testDrawDigit(uint8_t x, uint8_t y, uint8_t num, CRGB color);
    void drawDate(uint8_t month, uint8_t day, uint8_t dayOfWeek, CRGB dateColor);
    void displayError();
    
private:
    CRGB* leds;
    uint16_t LED_WIDTH;
    uint16_t LED_HEIGHT;
    uint16_t NUM_LEDS;
    DisplayLayout layout;
    
    // 颜色配置
    CRGB hourColor = CRGB(0, 100, 255);
    CRGB minColor = CRGB(0, 255, 100);
    CRGB secColor = CRGB(255, 200, 0);
    CRGB colonColor = CRGB(255, 50, 50);
    CRGB dateColor = CRGB(180, 0, 255); // 日期颜色
    CRGB weekActiveColor = CRGB(255, 0, 0);
    CRGB weekInactiveColor = CRGB(50, 50, 50);
    
    // 动画状态
    bool colonState = true;
    unsigned long lastColonBlink = 0;
    const uint16_t colonBlinkInterval = 500;
};

#endif